<extend name="Public/base"/>

<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

    <style>
        .comment_img img{width:200px; height: 150px; margin-right:10px;}
        .comment_title>span{margin-right:30px; font-size: 15px;}
        .tou_xiang{border-radius: 50%; width:50px; height: 50px; float: left; }

        .pinglun_list .userfz{ margin-right: 20px;}
        .pinglun_list{ min-height: 50px;  padding-top:10px;padding-bottom: 10px;margin-left:30px; border-bottom: 1px dashed #D4CFCF; }
        .btn_save,.btn_delete{color: red;margin-left:10px; cursor: pointer; margin-left:5px;}
        .btn_save:hover,.btn_delete:hover{text-decoration: underline;}
        .del_file{position: absolute;top: -7px;right: 5px;width: 17px;height: 17px;background: url(__IMG__/bg_icon.png) no-repeat -25px 0;cursor: pointer;}
    </style>

    <div class="main-title">
        <h2>评论内容</h2>
    </div>
    <ul class="tab-nav nav">
        <li class="current"><a href="javascript:void(0)">基本信息</a></li>
    </ul>
    
    <form action="{:U()}" method="post" class="form-horizontal">
        <input type="hidden" name="id" value="{$vo.id}" />
    <div class="tab-content">
        <div class="form-item">
            <label class="item-label comment_title"><span>发布人：{$vo['username']}</span><span>身份：{$vo['user_type']}</span><span>项目名称：{$vo['title']}</span></label>
            <div class="controls">
                <label class="textarea" style="width:800px;">
                <textarea name="content" class="save_cont" data-id="{$vo['id']}">{$vo['content']}</textarea>
                </label>
            </div>
        </div>
        <div class="form-item">
            <div class="controls">
                <div class="comment_img" style="width: 105%">
                    <volist name="vo['imgarr']" id="img">
                        <div class="comm_img" style="float: left; position: relative;">
                            <img src="{:picture($img)}" />
                            <span class="del_file" title="删除" data-id="{$vo['id']}" data-imgid="{$img}"></span>
                        </div>
                    </volist>
                </div>
			</div>
        </div>

        <div class="form-item">
            <div class="controls" style="border-top:1px solid #D4CFCF; ">

                    <volist name="son_list" id="son">
                        <div class="pinglun_list">
                            <img class="tou_xiang" src="{$son['icon']}" />
                            <div class="parent" style="width: 80%; float: left; margin-left:18px;margin-top: 14px;">
                                <span class="userfz">{$son['user_type']}</span>
                                <span class="cont2 cont_1">{$son['content']}<font class="btn_save">修改</font><font class="btn_delete" data-id="{$son['id']}">删除</font></span>
                                <span class="cont2 cont_2" style="display: none;"><input type="text" class="save_cont" value="{$son['content']}" style="width:80%; height: 30px;" data-id="{$son['id']}" /></span>
                            </div>
                        </div>
                    </volist>
            </div>
        </div>

        <div class="form-item" style="margin-top: 40px;">
           <!-- <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>-->
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </div>

    </form>

</block>

<block name="script">
<include file="Public:datetime" />
    <script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
    <script type="text/javascript">
	
		$('.tab-nav li').click(function(){
			$(this).attr('class','current')
						.siblings().attr('class','');
			var n_index=$('.tab-nav li').index(this);
				$('.tab-content').eq(n_index).show()
							 .siblings().hide();
		});
	
        //导航高亮
        highlight_subnav('{:U('Comment/index')}');

        $(".btn_save").click(function () {
            $(this).parent('.cont_1').hide();
            $(this).parents('.parent').find('.cont_2').show();
        });
        $(".save_cont").blur(function () {
            var ids = $(this).attr('data-id');
            var value =  $(this).val();
            var obj = $(this);
            $.post('/Admin/Ajax/save_message',{id:ids,value:value,model:'comment'},function (dd) {
                   if(dd.code==200){
                       layer.msg(dd.msg,{time:1000});
                       setTimeout(function () {
                          // obj.parent('.cont_2').hide();
                          // obj.parents('.parent').find('.cont_1').show();
                           window.location.reload();
                       },1000)
                   }else{
                       layer.msg(dd.msg);
                   }
            })
        });

        $(".btn_delete").click(function () {
            var id = $(this).attr('data-id');
            var obj = $(this);
            layer.confirm('确定要删除吗？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.post('/Admin/Ajax/deleinfo',{id:id,model:'comment'},function (dd) {
                    if(dd.code==200){
                        layer.msg(dd.msg,{time:1000});
                        setTimeout(function () {
                            obj.parents('.pinglun_list').remove();
                        },1000)
                    }else{
                        layer.msg(dd.msg);
                    }
                })
            });
        });

        //删除图片
        $(".del_file").click(function () {
            var id   = $(this).attr('data-id');
            var imgid = $(this).attr('data-imgid');
            var thiser = $(this);
            $.post('/Admin/Ajax/del_msgimg',{id:id,imgid:imgid},function (dd) {
                if(dd.code==200){
                    thiser.parent('.comm_img').remove();
                }else{
                    layer.msg(dd.msg);
                }
            });
        });


    </script>
</block>
